package main

import "fmt"

func main() {
	fmt.Println(lemonadeChange([]int{5, 5, 5, 10, 20}))
}

func lemonadeChange(bills []int) bool {
	countFive := 0
	countTen := 0
	for i := 0; i < len(bills); i++ {
		switch bills[i] {
		case 5:
			countFive++
		case 10:
			if countFive != 0 {
				countFive--
				countTen++
			} else {
				return false
			}
		case 20:
			if countTen != 0 && countFive != 0 {
				countTen--
				countFive--
			} else if countFive >= 3 {
				countFive -= 3
			} else {
				return false
			}
		}
	}
	return true
}
